package com.heima.admin.controller.v1;


import com.heima.admin.service.AdUserService;
import com.heima.apis.admin.AdUserControllerApi;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 管理员用户信息表 前端控制器
 * </p>
 *
 * @author liulei
 * @since 2021-01-08
 */
@RestController
@RequestMapping("/login")
@Api(tags = "登录注册模块")
public class LoginController implements AdUserControllerApi {

    @Autowired
    private AdUserService adUserService;


    /**
     * admin登录功能
     *
     * @param dto
     * @return
     */
    @PostMapping("/in")
    @Override
    @ApiOperation(value = "登录功能实现")
    public ResponseResult login(@RequestBody AdUserDto dto) {
        return adUserService.login(dto);
    }

    /**
     * 用户注册内部接口
     *
     * @param adUser
     * @return
     */
    @Override
    @PostMapping("register")
    @ApiOperation(value = "注册功能实现")
    public ResponseResult register(@RequestBody AdUser adUser) {
        return adUserService.register(adUser);
    }
}
